package com.utils;

import org.apache.commons.mail.DefaultAuthenticator;
import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;

/***
 * 该类是发送邮件的工具类
 */
public class SendMail {
    public static void sendEMail(String toEmailAddress, String emailTitle, String emailContent) throws EmailException {
        Email email = new SimpleEmail();
        email.setHostName("smtp.qq.com");
        email.setAuthenticator(new DefaultAuthenticator("xxjszyfwd@foxmail.com", "hzirqhagdpjedehj"));
        email.setSSLOnConnect(true);
        email.setCharset("UTF-8");
        email.setSubject(emailTitle);
        email.setFrom("xxjszyfwd@foxmail.com");
        email.setMsg(emailContent);
        email.addTo(toEmailAddress);
        email.send();
    }
}



